{include file="public/header" /}
<body class="gray-bg">
    <div class="wrapper wrapper-content">

             <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
<form id="myForm" class="form-horizontal m-t" method="post" action="{:url('update')}">
						<input type="hidden" name="id" value="{$data.id}">
					<div class="form-group">
						<label class="col-sm-3 control-label">应用场景：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="title" name="title" placeholder="应用场景" class="form-control" value="{$data.title}" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">短信分类：</label>
						<div class="input-group col-sm-4">
							<select name="type" class="form-control" value="">
								<option value="1" {if $data.type==1}selected{/if}>验证码</option>
								<option value="2" {if $data.type==2}selected{/if}>短信通知</option>
								<option value="3" {if $data.type==3}selected{/if}>推广短信</option>
								<option value="4" {if $data.type==4}selected{/if}>语音通知</option>
								<option value="5" {if $data.type==5}selected{/if}>群发助手</option>
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">短信签名：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="sign_name" name="sign_name" placeholder="短信签名" class="form-control" value="{$data.sign_name}"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">模板ID：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="tid" name="tid" placeholder="模板ID" class="form-control"  value="{$data.tid}"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">模板参数：</label>
						<div class="input-group col-sm-4">
							<input type="text" id="params" name="params" placeholder="模板参数" class="form-control"  value="{$data.params}"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3">
							<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;
							<a href="{:url('index')}" class="btn btn-danger"><i class="fa fa-arrow-left"></i> 返回 </a>
						</div>
					</div>
				</form>

                    </div>
                </div>
            </div>
        </div>
    </div>
{include file="public/footer" /}
</body>


<script type="text/javascript">
$(function() {
				$('#myForm').ajaxForm({
					beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置      
					success: complete, // 这是提交后的方法
					dataType: 'json'
				});

				function checkForm() {
					if('' == $.trim($('#title').val())) {
						layer.msg('请输入应用场景');
						return false;
					}

					if('' == $.trim($('#sign_name').val())) {
						layer.msg('请输入短信签名');
						return false;
					}

					if('' == $.trim($('#tid').val())) {
						layer.msg('请输入模板ID');
						return false;
					}
					if('' == $.trim($('#params').val())) {
						layer.msg('请输入模板参数');
						return false;
					}

				}

				function complete(data) {
						 if(data.code==200){
               			 layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                  				  window.location.href="{:url('index')}";
               					 });
          			 		 }else{
               					 layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1});
               							 return false;   
          					  }
				}

			});
</script>
</html>